package com.fare.taluo.core.domain.config.line.impl;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;
import com.dayatang.domain.DataPage;
import com.dayatang.domain.QuerySettings;
import com.dayatang.hibernate.EntityRepositoryHibernate;
import com.fare.taluo.util.StringAndDateAndFileUtil;
import com.fare.taluo.vo.core.FreightPublishVO;
import com.fare.taluo.core.domain.config.line.FreightPublishEntity;
import com.fare.taluo.core.domain.config.line.FreightPublishEntityRepository;
@Repository
public class FreightPublishEntityRepositoryImpl extends
		EntityRepositoryHibernate implements FreightPublishEntityRepository {

	@Override
	public List<FreightPublishEntity> findAll() {
		return super.find("from FreightPublishEntity",new Object[]{},FreightPublishEntity.class);
	}

	@Override
	public void remove(FreightPublishEntity entity) {
		super.remove(entity);
	}

	@Override
	public void saveOrUpdate(FreightPublishEntity entity) {
		super.save(entity);
	}
     
	@Override
	public List<FreightPublishEntity> findFreightPublishByCondition(int pageNum,
			int pageSize) {
		List<Object> list = new ArrayList<Object>();
		String hql = "from FreightPublishEntity";
		DataPage<FreightPublishEntity> page = find(hql, list.toArray(), pageNum, pageSize,FreightPublishEntity.class);	
		return page.getPageData();
	}
	
	public FreightPublishEntity findByLine(String fromCity,String toCity){
		return super.getSingleResult(QuerySettings.create(FreightPublishEntity.class)
				.eq("fromCity", fromCity)
				.eq("toCity", toCity));
	}

}
